﻿import QtQuick 2.0

Rectangle {
    property int pageIndex: 0
    property string imgSource
    property string imgSourceLight
    property bool checked: false
    signal btnClicked()

    width: 112
    height: 102
    color: checked ? "#0085FF" : Qt.rgba(0,0,0,0)
    border.width: 0
    radius: 23
    Image{
        id: iconImg
        anchors.centerIn: parent
        fillMode: Image.PreserveAspectFit
        sourceSize.width: 42
        sourceSize.height: 42
        source: imgSource
    }
    MouseArea{
        anchors.fill: parent
        onClicked: {
            checked=true
            btnClicked()
        }
    }

    onCheckedChanged: {
        color = checked ? "#0085FF" : Qt.rgba(0,0,0,0)
        iconImg.source = ""
        iconImg.source = checked ? imgSourceLight : imgSource
    }

    Component.onCompleted: {
        imgSourceLight = imgSource.substring(0, imgSource.lastIndexOf('.')) + "_2.png";
    }
}
